{extend name="public/base" /}
{block name="body"}
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header">
                插件列表
            </div>
            <div class="layui-card-body">
                <div class="layui-tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">
                            本地插件
                        </li>
                        <li>
                            <a href="https://www.kaifashu.com/addon/lists" target="_blank">插件库</a>
                        </li>
                    </ul>
                    <div class="layui-tab-content layui-row">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-row zz-row-operate">
                                <div class="zz-operate-btn-group">
                                    <button type="button" class="layui-btn" id="local_instal_addons">
                                        <i class="layui-icon">&#xe67c;</i>安装插件
                                    </button>
                                </div>
                            </div>
                            <blockquote class="layui-elem-quote">
                                在插件库下载插件后，点击“安装插件”，选择插件文件压缩包进行安装。
                            </blockquote>
                            <div class="layui-form zz-table-list-container">
                                <table class="layui-table">
                                    <thead>
                                    <tr>
                                        <th>插件</th>
                                        <th>作者</th>
                                        <th>版本</th>
                                        <th>状态</th>
                                        <th>
                                            操作
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name="lists" id="vo"}
                                    <tr>
                                        <td>
                                            <p><b>{$vo.title}</b></p>
                                            <p class="check-tips">{$vo.description}</p>
                                        </td>
                                        <td>
                                            {$vo.author}
                                        </td>
                                        <td>
                                            {$vo.version}
                                        </td>
                                        <td>
                                            <input type="checkbox" lay-filter="zz-switch"  data-href="{:url('enable?name='.$vo['name'])}" name="status"
                                                   value="{$vo.status==1?'0':'1'}" {$vo.status==1?'checked':''} lay-skin="switch" lay-text="启用|禁用">
                                        </td>
                                        <td>
                                            {if isset($vo.config)&&$vo.config==1}
                                            <a href="{:url('config?name='.$vo['name'])}" class="layui-btn layui-btn-xs layui-btn-normal open-win" title="编辑">配置</a>
                                            {/if}
                                            <a href="{:url('del?name='.$vo['name'])}" class="layui-btn layui-btn-danger layui-btn-xs confirm ajax-post">卸载</a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                                {if empty($lists)}
                                <div class="zz-data-empty">
                                    <i class="layui-icon layui-icon-tips"></i>暂无记录！
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    var upload = layui.upload;
    //执行实例
    var uploadInst = upload.render({
        elem: '#local_instal_addons' //绑定元素
        ,url: '{:url("local")}' //上传接口
        ,acceptMime:'application/zip'
        ,exts:'zip'
        ,before:function () {
            layer.load();
        }
        ,done: function(res){
            //上传完毕回调
            layer.closeAll('loading');
            if(res.code==1){
                zzSuccess(res.msg,2,function () {
                    location.reload();
                })
            }else{
                zzError(res.msg);
            }
        }
        ,error: function(){
            //请求异常回调
            layer.closeAll('loading');
        }
    });
</script>
{/block}